import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login'
import Locks from '../views/Locks'
import LockEdit from "../views/LockEdit";
import LockDetail from "../views/LockDetail";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/locks',
    name: 'Locks',
    //懒加载
    component: () => import('../views/Locks.vue')
  },
  {
    path: '/lock/add',//放在path:'/blog/:blogId'之前
    name: 'LockAdd',
    meta: {
      requireAuth: true //meta：requireAuth: true说明是需要登录字后才能访问的受限资源，后面我们路由权限拦截时候会用到
    },
    component: LockEdit
  },
  {
    path: '/lock/:lockId',
    name: 'LockDetail',
    component: LockDetail
  },
  {
    path: '/lock/:lockId/edit',
    name: 'LockEdit',
    meta: {
      requireAuth: true
    },
    component: LockEdit
  }
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
